package com.idealighter.game.recharge.handler;

import com.google.inject.Inject;

import com.idealighter.game.core.annotation.ReqMsgHandler;
import com.idealighter.game.message.ModuleMsgIdConstant;
import com.idealighter.game.message.core.ReqMessage;
import com.idealighter.game.message.core.ResMessage;
import com.idealighter.game.player.struct.Player;
import com.idealighter.game.recharge.manager.RechargeMgr;
import com.idealighter.game.recharge.message.ReqRechargePayMsg;
import com.idealighter.game.recharge.message.ReqRechargePayMsg.PayType;
import com.idealighter.game.server.handler.ReqMessageHandler;

@ReqMsgHandler(ModuleMsgIdConstant.Recharge.RECHARGE_PAY)
public class ReqRechargePayHandler implements ReqMessageHandler {

  @Inject
  private RechargeMgr rechargeMgr;

  @Override
  public ResMessage action(Player player, ReqMessage msg) {
    ReqRechargePayMsg payMsg = (ReqRechargePayMsg) msg;
    PayType payType = null;
    if (payMsg.getPayType() == PayType.WE_CHAT_PAY.getId()) {
      payType = PayType.WE_CHAT_PAY;
    } else if (payMsg.getPayType() == PayType.ALI_PAY.getId()) {
      payType = PayType.ALI_PAY;
    } else if (payMsg.getPayType() == PayType.APPLE_IN_APP_PAY.getId()) {
      payType = PayType.APPLE_IN_APP_PAY;
    }
    return rechargeMgr.rechargePay(player, payMsg.getItemId(), payType);
  }
}
